﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _80X_CG_Frame.Interfaces
{
    /// <summary>
    /// 公用异步TcpClient接口
    /// </summary>
    public interface IAsyncClient
    {
        /// <summary>
        /// 连接状态
        /// </summary>
        bool IsConnect { get; }
        /// <summary>
        /// 异步连接
        /// </summary>
        /// <param name="ip"></param>
        /// <param name="port"></param>
        /// <param name="times">重连次数</param>
        /// <returns>连接状态</returns>
        Task<bool> ConnectAsync(string ip, int port, int times = 5);
        /// <summary>
        /// 异步连接,地址示例:127.0.0.1:12450
        /// </summary>
        /// <param name="address">完整的地址</param>
        /// <param name="times">重连次数</param>
        /// <returns>连接状态</returns>
        Task<bool> ConnectAsync(string address, int times = 5);
        //bool ClientIsConnect();
        /// <summary>
        /// 断开连接
        /// </summary>
        void DisConnect();
        /// <summary>
        /// 连接状态改变通知事件
        /// </summary>
        event PropertyChangedEventHandler PropertyChanged;
    }
}
